<?
	session_start();//启用session
	header("Content-type:text/html;charset=utf-8");
	date_default_timezone_set('PRC'); //调整时区
	if (!empty($_SESSION["time"])) {
		//以session方式输出
		echo '<html><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /><style>html,body,iframe{width:100%;height:99.5%;padding:0;margin:0}#wrap{width:100%;height:100%}iframe{border:0}</style><div id="wrap"><iframe src="'.$url.'/tips.php?context=你好，'.$_SESSION["username"].'<br>登录成功，即将跳转~'.'"></iframe></div></html>';
		header("Refresh:2;url=index.php?do=upload");
	}else{
	$post=$_POST;
	include __DIR__.'/login_user.php';
	
	if ($post['username']!=="" and $post['password']!==""){	
		foreach($login as $value){
			$arr=explode("|",$value);
			$arr_user=$arr[0];
			$arr_pass=$arr[1];
			if($post['username']==$arr_user){
				if(md5($post['password'])==$arr_pass){
					$login_code=100;
					$login_user=$arr_user;
					$login_pass=$arr_pass;
					break;
				}else{
					$login_code=400;
					break;
				}
			}
		}
		if($login_code!=100 and $login_code!=400){
				$login_code=50;
			}
	switch ($login_code){
		case 100:
			$_SESSION["username"] = $login_user;
			$_SESSION["time"] = time();
			if (!empty($_SESSION["time"])) {
				header("Refresh:0");
		  }
		  break;  
		case 400:
		  echo '<html><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /><style>html,body,iframe{width:100%;height:99.5%;padding:0;margin:0}#wrap{width:100%;height:100%}iframe{border:0}</style><div id="wrap"><iframe src="/tips.php?context=密码错误"></iframe></div></html>';
		  header("Refresh:3;url=index.php?do=login");
		  break;
		case 50:
		  echo '<html><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /><style>html,body,iframe{width:100%;height:99.5%;padding:0;margin:0}#wrap{width:100%;height:100%}iframe{border:0}</style><div id="wrap"><iframe src="/tips.php?context=用户不存在，请联系QQ2135820046"></iframe></div></html>';
		  header("Refresh:2;url=index.php?do=login");
		  break;
		default:
		echo '<html><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /><style>html,body,iframe{width:100%;height:99.5%;padding:0;margin:0}#wrap{width:100%;height:100%}iframe{border:0}</style><div id="wrap"><iframe src="/tips.php?context=未知错误"></iframe></div></html>';
		  header("Refresh:2;url=index.php?do=login");
		  break;
		}
	}else{
		echo '<html><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /><style>html,body,iframe{width:100%;height:99.5%;padding:0;margin:0}#wrap{width:100%;height:100%}iframe{border:0}</style><div id="wrap"><iframe src="/tips.php?context=请输入正确的账号密码"></iframe></div></html>';
		header("Refresh:2;url=index.php?do=login");
	}
}
?>